home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / cjdates.exe / DATES.INC < prev    next >
Text File  |  1991-07-07  |  2KB  |  60 lines

  1. {
  2.                   dates.inc
  3.  
  4.  This Turbo Pascal Include file contains several routines to aid in date
  5.  processing and display.
  6.  
  7.  YDay, given a Gregorian date, returns the Julian Day of the Year.
  8.  
  9.  DOW, given a number 0-6 returns a string giving the Day of the Week.
  10.  
  11.  MonthName, given a month number (1-12) returns the name of the month.
  12.  
  13.  WARNING! Don't forget that "YDay" requires that you place a "uses Dates"
  14.  at the beginning of the program!!!
  15.  
  16.  AND REMEMBER--The Year you supply to YDay must be the full year, NOT the
  17.  last two digits!!}
  18.                         {(c)Copyright 1991 Crazy Jack}
  19.                              {All Rights Reserved}
  20.  
  21. {----------------------------------- YDay -----------------------------------}
  22.  
  23.  function YDay( Year, Month, Day : word   {Caller-supplied Gregorian date.}
  24.                    ) : word;  {Function returns Julian year-day.}
  25.  begin
  26.    YDay := word( ZDay(Year, Month, Day) - ZDay(Year, 1, 0) )
  27.  end;
  28.  
  29. {------------------- Type used by BOTH DOW and MonthName --------------------}
  30.  
  31.  type
  32.    DatesStr9 = string[9];        {No need to allocate 256 bytes}
  33.                     {somewhere.}
  34.  
  35. {----------------------------------- DOW ------------------------------------}
  36.  
  37.  function DOW( DNmbr : word        {Caller-supplied day-of-week number.}
  38.           ) : DatesStr9;    {Returned string naming the day.}
  39.  const
  40.    WT : array[0..7] of DatesStr9 = ('Sunday', 'Monday', 'Tuesday',
  41.                     'Wednesday', 'Thursday', 'Friday',
  42.                     'Saturday', 'NotADay');
  43.  begin
  44.    DOW := WT[DNmbr and 7]
  45.  end;
  46.  
  47. {-------------------------------- MonthName ---------------------------------}
  48.  
  49.  function MonthName( MNmbr : word    {Caller-supplied month number.}
  50.              ) : DatesStr9; {Returned string naming the month.}
  51.  const
  52.    MT : array[0..15] of DatesStr9 = ('Caligula', 'January', 'February',
  53.                      'March', 'April', 'May', 'June',
  54.                      'July', 'August', 'September', 'October', 
  55.                      'November', 'December', 'Caligula', 
  56.                      'Caligula', 'Caligula');
  57.  begin
  58.    MonthName := MT[MNmbr and 15]
  59.  end;
  60.